package com.haiya.state.threadstate;

public class RunnableState extends ThreadState {
    public RunnableState() {
        threadName = "就绪状态";
        System.out.println("当前线程处于就绪状态.~~~~~");
    }

    public void getCPU(ThreadContext context) {
        System.out.print("调用getCPU()方法-->");
        if (threadName.equals("就绪状态")) {
            context.setState(new RunningState());
        } else {
            System.out.println("当前线程不是新建状态，不能调用getCPU()方法.");
        }
    }
}
